package com.example.growthmuseum;

import com.alibaba.fastjson.JSON;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class ServiceFactory {

    private final static String IP = "192.168.253.1";

    private final static String PORT = "8080";

    public final static String BASE_URL = "http://" + IP + ":" + PORT + "/" +
            "growth-museum/";


    public static <T> T createRetrofitService(final Class<T> clazz, final String baseUrl) {

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

        return retrofit.create(clazz);
    }
}